package com.jinxin.platform.cdacsrecord.core.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinxin.platform.cdacsrecord.core.mapper.JurenAcsControlRecordInfoMapper;
import com.jinxin.platform.cdacsrecord.core.pojo.domains.AcsControlRecordInfo;
import com.jinxin.platform.cdacsrecord.core.service.AcsControlRecordInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * (AcsControlRecordInfo)表服务实现类
 *
 * @author makejava
 * @since 2020-04-15 14:09:17
 */
@Service("acsControlRecordInfoService")
public class AcsControlRecordInfoServiceImpl implements AcsControlRecordInfoService {
    @Resource
    private JurenAcsControlRecordInfoMapper jurenAcsControlRecordInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param acsRecordId 主键
     * @return 实例对象
     */
    @Override
    public AcsControlRecordInfo queryById(String acsRecordId) {
        return this.jurenAcsControlRecordInfoDao.queryById(acsRecordId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<AcsControlRecordInfo> queryAllByLimit(int offset, int limit) {
        return this.jurenAcsControlRecordInfoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param acsControlRecordInfo 实例对象
     * @return 实例对象
     */
    @Override
    public AcsControlRecordInfo insert(AcsControlRecordInfo acsControlRecordInfo) {
        this.jurenAcsControlRecordInfoDao.insert(acsControlRecordInfo);
        return acsControlRecordInfo;
    }

    /**
     * 修改数据
     *
     * @param acsControlRecordInfo 实例对象
     * @return 实例对象
     */
    @Override
    public AcsControlRecordInfo update(AcsControlRecordInfo acsControlRecordInfo) {
        this.jurenAcsControlRecordInfoDao.update(acsControlRecordInfo);
        return this.queryById(acsControlRecordInfo.getAcsRecordId());
    }

    /**
     * 通过主键删除数据
     *
     * @param acsRecordId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String acsRecordId) {
        return this.jurenAcsControlRecordInfoDao.deleteById(acsRecordId) > 0;
    }


    @Override
    public PageInfo<AcsControlRecordInfo> queryPageByLimit(int offset, int limit, AcsControlRecordInfo acsControlRecordInfo,
                                                           String beginTime, String endTime,
                                                           String listenBeginTime, String listenEndTime ){
        PageHelper.startPage(offset,limit);
        List<AcsControlRecordInfo> recordInfoList = jurenAcsControlRecordInfoDao.queryAll(acsControlRecordInfo,  beginTime,  endTime,
                 listenBeginTime,  listenEndTime );
        PageInfo<AcsControlRecordInfo> pageInfo = new PageInfo<>(recordInfoList);
        return pageInfo;
    }

    @Override
    public AcsControlRecordInfo queryByInfo(String info) {
        return jurenAcsControlRecordInfoDao.queryByInfo(info);
    }

    @Override
    public PageInfo<AcsControlRecordInfo> queryPageByLimitApp(int offset, int limit, String deviceId, String listenType) {
        PageHelper.startPage(offset,limit);
        List<AcsControlRecordInfo> recordInfoList = jurenAcsControlRecordInfoDao.selAPPCallRecord(deviceId,listenType );
        PageInfo<AcsControlRecordInfo> pageInfo = new PageInfo<>(recordInfoList);
        return pageInfo;

    }

    @Override
    public PageInfo<AcsControlRecordInfo> queryInvitePageByLimitApp(int offset, int limit, String state,String uid) {
        PageHelper.startPage(offset,limit);
        List<AcsControlRecordInfo> recordInfoList = jurenAcsControlRecordInfoDao.selAPPInviteRecord(state, uid );
        PageInfo<AcsControlRecordInfo> pageInfo = new PageInfo<>(recordInfoList);
        return pageInfo;
    }

}